package com.fltry.myarouoter;

import android.app.Activity;
import android.content.Intent;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.fltry.commom.ARouterActivity;
import com.fltry.commom.Bean;
import com.fltry.commom.GlobalValues;

@Route(path = GlobalValues.ACTIVITY_URL_MAIN)
public class MainActivity extends ARouterActivity {
    TextView tv;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_main);
        tv = findViewById(R.id.tv);
        findViewById(R.id.btn1).setOnClickListener(v ->
                ARouter.getInstance()
                        .build(GlobalValues.ACTIVITY_URL_WORK)
                        .withString("strValue", "我是一个String字符串")
                        .withInt("intValue", 123456)
                        .withBoolean("booleanValue", true)
                        .withSerializable("bean", new Bean("我是一个对象"))
                        .navigation(this, 1));
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK && data != null && requestCode == 1) {
            tv.setText(data.getStringExtra("result"));
        }
    }

}
